/*this program used to find the index of the elments which sum is traget  in the array.*/
/***nums=[2,7,11,15], target=9***/

#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

class soultion
{
public:
    vector<int> twosum(vector<int> &nums,int target)
    {
        vector<int> ans;
        for(int i=0;i<nums.size();i++)
        {
            for(int j=i+1;j<nums.size();j++)
            {
                if(nums[i]+nums[j]==target)
                {
                    ans.push_back(i);
                    ans.push_back(j);
                    return ans;
                }
            }
        }
        return ans;
    }
};

int main()
{
    soultion a;
    int num[]={2,7,11,15},target=13;
    vector<int> nums;
    for(int i=0;i<4;i++)
    {
      nums.push_back(num[i]);
    }
    
    vector<int> ans;
    ans=a.twosum(nums,target);
    for(int i=0;i<2;i++)
        cout<<ans[i]<<endl;

    system("pause");
    return 0;
}